package com.atguigu.gulimall.order.vo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单确认页要用到的数据
 * @author starsPromise
 */

public class OrderConfirmVo {
    /**
     * 收货地址
     */
    private List<MemberAddressVo> addressVos;
    /**
     * 所有选中的购物项
     */
    private List<OrderItemVo> itemVos;

    /**
     * 发票记录
     */

    /**
     * 优惠券信息
     */
    private Integer integration;
    /**
     * 防重令牌
     */
    String orderToken;

    Map<Long,Boolean> stocks;


    public List<MemberAddressVo> getAddressVos() {
        return addressVos;
    }

    public void setAddressVos(List<MemberAddressVo> addressVos) {
        this.addressVos = addressVos;
    }

    public List<OrderItemVo> getItemVos() {
        return itemVos;
    }

    public void setItemVos(List<OrderItemVo> itemVos) {
        this.itemVos = itemVos;
    }

    public Integer getIntegration() {
        return integration;
    }

    public void setIntegration(Integer integration) {
        this.integration = integration;
    }

    /**
     * 订单总额
     */
    public BigDecimal getTotal() {
        BigDecimal total=new BigDecimal("0");
        if(this.itemVos!=null){
            for (OrderItemVo itemVo : this.itemVos) {
                total=total.add(itemVo.getPrice().multiply(new BigDecimal(itemVo.getCount())));

            }
        }

        return total;
    }

    public Integer getCount(){
        Integer count=0;
        if(this.itemVos!=null){
            for (OrderItemVo itemVo : this.itemVos) {
                count+= itemVo.getCount();

            }
        }

        return count;
    }

    /**
     * 应付总额
     */
    public BigDecimal getPayPrice() {
        return getTotal();
    }

    public String getOrderToken() {
        return orderToken;
    }

    public void setOrderToken(String orderToken) {
        this.orderToken = orderToken;
    }

    public Map<Long, Boolean> getStocks() {
        return stocks;
    }

    public void setStocks(Map<Long, Boolean> stocks) {
        this.stocks = stocks;
    }
}
